<div id="wrapper" class="annotations">
	<div id="content">
		<div id="main">
			<div class="main-heading">
				<h1><?php echo $book->getTitle(); ?></h1>
			</div>

			<div id="book-introduction">
				<img src="/images/img_annotation-sample.gif" alt="Sample" />
				<div class="details">
					<h2><?php echo link_to('Essay', 'books/showEssay?id='.$book->getId()) ?></h2>

					<p>
						<?php
							if(strlen(stripslashes($book->getEssay())) > 1000) {
								echo substr(stripslashes($book->getEssay()),0,995) . ' ....';
							} else {
								echo stripslashes($book->getEssay());
							}
						?>
					</p>
				</div>
			</div>

			<h4><span>Sections</span></h4>
			<ul class="sections-list">
				<?php foreach($sections as $section) : ?>
					<?php if(!is_array($section)) : ?>
		<li><a href="#<?php echo $section->getId(); ?>"><?php echo $section->getName(); ?></a></li>
					<?php endif; ?>
				<?php endforeach; ?>
			</ul>

			<?php for($i=0;$i<count($sections);$i++) : ?>
				<?php 
					$section = $sections[$i]; 
					if($i < count($sections) -1 ) $next = $sections[$i + 1]; 
				?>
					<?php if(is_array($section)) : ?>
						<ul>
						<?php foreach($section as $sec) : ?>
							<li><?php echo link_to(stripslashes($sec->getName()), 'books/showSection?id='.$sec->getId().'&bookid='.$book->getId()) ?></li>
						<?php endforeach; ?>
						</ul>
						</div>
					<?php else : ?>
						<div class="book-section">
							<h3><a name="<?php echo $section->getId(); ?>"></a>
							
						<?php if(!$next || !is_array($next)) : ?>
							<?php echo link_to(stripslashes($section->getName()), 'books/showSection?id='.$section->getId().'&bookid='.$book->getId()) ?>
							</h3>
							</div>
						<?php else : ?>
							<?php echo stripslashes($section->getName()); ?>
							</h3>
						<?php endif; ?>
					<?php endif; ?>
				<?php endfor; ?>
		</div>

		<div id="sidebar">
			<div class="module books">
				<h3 class="gradient light">About this Book</h3>
				<div class="inner">
					<ul>
						<li class="last">
							<h4><?php echo stripslashes($book->getTitle()); ?></h4>
							<p><?php echo stripslashes($book->getAuthor()); ?></p>
						</li>
					</ul>
					<p><?php echo stripslashes($book->getSummary()); ?></p>
				</div>
			</div>
		</div>
	</div>
</div>
